package gaboli.common.utils;

/**
 * Very simple random Alphanumeric String generator. This will produce URL-safe strings.
 *
 * @author C. Burrell (deltafront@gmail.com)
 */
public class AlphaNumGen
{
    /**
     * Produces an URL-safe alphanumeric string based on the specified string.
     *
     * @param string String to be made into a URL-safe string.
     * @return URL-safe alphanumeric string.
     * @since 1.0
     */
    public String generate( String string )
    {
        return generate( string, true );
    }

    /**
     * Produces an alphanumeric string that is optionally URL-Safe that based on the specified string.
     *
     * @param string  String to be converted.
     * @param url_safe whether or not this string is URL safe (consists mostly of alphanumeric characters).
     * @return alphanumeric String.
     * @since 1.0
     */
    public String generate( String string, boolean url_safe )
    {
        EncryptionUtils encryptionUtils = new EncryptionUtils();
        return encryptionUtils.randomSalt( encryptionUtils.randomSalt( string ), url_safe );
    }
}